//package com.software.graduationproject.commons.handler;
//
//import com.alibaba.fastjson.JSON;
//import com.software.graduationproject.commons.enums.ResultCodes;
//import com.software.graduationproject.commons.util.Result;
//import com.software.graduationproject.commons.util.Results;
//import com.software.graduationproject.commons.util.WebUtils;
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.web.access.AccessDeniedHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Component
//public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
//    @Override
//    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
//        Result failure = Results.failure(ResultCodes.FAILURE_AUTHORIZE_DENIED.getStatus(), ResultCodes.FAILURE_AUTHORIZE_DENIED.getMessage());
//        String jsonString = JSON.toJSONString(failure);
//        // 处理授权异常
//        WebUtils.renderString(httpServletResponse, jsonString);
//    }
//}
